package com.mudalov.rec.dao.model.user;

import com.mudalov.rec.dao.interfaces.IClonable;
import java.util.Set;

import com.mudalov.rec.dao.model.study.Subject;

public class Teacher extends User implements IClonable<Teacher> {

	private static final long serialVersionUID = -351941013693296464L;
	
	private Subject subject;
	
	public Teacher() {}

	public Teacher(String fullName, String login, String eMail, Set<Message> messages,
			String password, Role role, Subject subject) {
		super();
        this.eMail = eMail;
		this.fullName = fullName;
		this.login = login;
		this.messages = messages;
		this.password = password;
		this.role = role;
		this.subject = subject;
	}

	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}

        @Override
    public boolean isAdmin() {
        return false;
    }

    @Override
    public boolean isTeacher() {
        return true;
    }

    @Override
    public boolean isStudent() {
        return false;
    }

    public Teacher getClone() {
        Teacher clone = new Teacher();
        clone.setFullName(this.getFullName());
        clone.setId(this.getId());
        clone.setLogin(this.getLogin());
        clone.setMail(this.getMail());
        if (this.getMessages() != null) {
            for (Message message : this.getMessages()) {
                clone.getMessages().add(message.getClone());
            }
        }

        clone.setPassword(this.getPassword());
        if (this.getRole() != null) {
            clone.setRole(this.getRole().getClone());
        }
        if (this.getSubject() != null) {
            clone.setSubject(this.getSubject().getClone());
        }
        clone.setMail(this.getMail());
        return clone;
    }
}
